﻿#include <QApplication>
#include "mainwindow.h"
#include "loginform.h"
#include "sensordataop.h"

int main(int argc,char** argv)
{
    QApplication app(argc,argv);
    MainWindow *main = new MainWindow();
    main->setWindowTitle(QString::fromLocal8Bit("智慧大棚环境信息监控系统"));//设置窗体标题
    //测试sensordatatable

    SensorData data;
    data.DeviceId = "1114";
    data.SensorAddr = 1;
    data.AirTemp = 32.10;
    data.AirDamp = 48.90;
    data.SoilTemp = 28.88;
    data.SoilDamp = 58.76;
    data.LightValue = 89.0;
    data.CO2 = 32.88;
    data.O2 = 29.8;
    data.Time = QDateTime::currentDateTime();

    SensorDataOp *sensordataOp = new SensorDataOp();
    MySql *mysql = new MySql();
    sensordataOp->InsertSensorDataToDb(mysql->db,data);

    LoginForm login;
    if (login.exec() == QDialog::Accepted)//调用login.exec()，阻塞主控制流，直到完成返回，继续执行主控制流
    {
       main->setWindowState(Qt::WindowMaximized);
       main->show();
       return app.exec();
    }
    else return 0;
}
